package com.itheima.stock.mapper;

import com.itheima.stock.common.domian.RoleAddDomain;
import com.itheima.stock.pojo.SysRole;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;

/**
* @author hyn
* @description 针对表【sys_role(角色表)】的数据库操作Mapper
* @createDate 2022-05-30 01:02:49
* @Entity com.itheima.stock.pojo.SysRole
*/
@Repository
public interface SysRoleMapper {

    int deleteByPrimaryKey(Long id);

    int insert(SysRole record);

    int insertSelective(SysRole record);

    SysRole selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(SysRole record);

    int updateByPrimaryKey(RoleAddDomain roleAddDomain );

    List<SysRole> getUserByPageInfo();

    boolean addRoles(RoleAddDomain roleAddDomain);

    @Insert("INSERT INTO sys_role_permission values (#{rid},#{id},#{pid},#{date})")
    int insertRolesAndPermission(@Param("rid") Long rid,@Param("id") Long id , @Param("pid") String permissionsId,  @Param("date")Date date);

    @Update("update sys_role set status =#{status} where id =#{rid} ")
    boolean updateRoleStatus(@Param("rid") String roleId, @Param("status") Integer status);
}
